using System;
using System.Collections.Generic;
using System.Text;

namespace XnaDevRu.BulletX.LinearMath
{
	internal class Vector4 : Vector3
	{
		public Vector4() { }

		public Vector4(float x, float y, float z, float w)
			: base(x, y, z) { W = w; }

		public static Vector4 Absolute4(Vector4 a)
		{
			return new Vector4(
				Math.Abs(a.X),
				Math.Abs(a.Y),
				Math.Abs(a.Z),
				Math.Abs(a.W));
		}

		public int MaxAxis4()
		{
			int maxIndex = -1;
			float maxVal = -1e30f;
			if (X > maxVal)
			{
				maxIndex = 0;
				maxVal = X;
			}
			if (Y > maxVal)
			{
				maxIndex = 1;
				maxVal = Y;
			}
			if (Z > maxVal)
			{
				maxIndex = 2;
				maxVal = Z;
			}
			if (W > maxVal)
			{
				maxIndex = 3;
				maxVal = W;
			}

			return maxIndex;
		}

		public int MinAxis4()
		{
			int minIndex = -1;
			float minVal = 1e30f;
			if (X < minVal)
			{
				minIndex = 0;
				minVal = X;
			}
			if (Y < minVal)
			{
				minIndex = 1;
				minVal = Y;
			}
			if (Z < minVal)
			{
				minIndex = 2;
				minVal = Z;
			}
			if (W < minVal)
			{
				minIndex = 3;
				minVal = W;
			}

			return minIndex;
		}

		public int ClosestAxis4()
		{
			return Absolute4(this).MaxAxis4();
		}

		public static explicit operator Microsoft.Xna.Framework.Vector4(Vector4 a)
		{
			return new Microsoft.Xna.Framework.Vector4(a.X, a.Y, a.Z, a.W);
		}
	}
}
